1712A - Wonderful Permutation - CodeForces Solution


implementation

Please click on ads to support us..

Python Code:

for _ in range(int(input())):
	n,k=map(int,input().split())
	a=list(map(int,input().split()))
	c=0
	for i in range(k):
		if(a[i]>k):c+=1
	print(c)

C++ Code:

#include <iostream>
using namespace std;
int main()
{
    int t, n, k, temp, count;
    cin >> t;
    while (t--)
    {
        cin >> n >> k;
        count = 0;
        for (int j = 0; j < k; j++)
        {
            cin >> temp;
            if (temp > k)
                count++;
        }
        for (int j = 0; k + j < n; j++)
        {
            cin >> temp;
        }
        cout << count << endl;
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1088B - Ehab and subtraction
1270B - Interesting Subarray
478C - Table Decorations
1304C - Air Conditioner
1311C - Perform the Combo
1519C - Berland Regional
361A - Levko and Table
5E - Bindian Signalizing
687A - NP-Hard Problem
1542C - Strange Function
961E - Tufurama
129D - String
888A - Local Extrema
722B - Verse Pattern
278A - Circle Line
940A - Points on the line
1742C - Stripes
1742F - Smaller
1742B - Increasing
1742A - Sum
1742D - Coprime
390A - Inna and Alarm Clock
1398B - Substring Removal Game
1742G - Orray
416B - Art Union
962A - Equator
803B - Distances to Zero
291A - Spyke Talks
1742E - Scuza
1506D - Epic Transformation